// winit 库的学习
// https://crates.io/crates/winit

use winit::{
    event::*,
    event_loop::{ControlFlow, EventLoop},
    window::WindowBuilder,
};

fn main() {
    let event_loop = EventLoop::new();
    let window = WindowBuilder::new().build(&event_loop).unwrap();

    event_loop.run(move | event, _, control_flow| {
        control_flow.set_poll();

        control_flow.set_wait();

        match event {
            Event::WindowEvent { 
                event:WindowEvent::CloseRequested,
                ..
            } => {
                println!("关闭按钮");
                control_flow.set_exit();
            },
            Event::MainEventsCleared => {
                window.request_redraw();
            },
            Event::RedrawRequested(_) => {
                // redraw
            },
            _ => ()
        }

    });


}